home *** CD-ROM | disk | FTP | other *** search
- /* cat > ./ax25dump.c << '\Rogue\Monster\' */
- #include <stdio.h>
- #include "global.h"
- #include "mbuf.h"
- #include "ax25.h"
- #include "timer.h"
- #include "lapb.h"
- #include "trace.h"
-
- #define uchar(c) (c & 0xff)
-
- /*
- char
- uchar(c)
- char c;
- {
- return (c & 0xff);
- }
- */
-
- /* Dump an AX.25 packet header */
- ax25_dump(bpp,check)
- struct mbuf **bpp;
- int check; /* Not used */
- {
- char *decode_type();
- char tmp[20];
- char control,pid;
- int16 type,ftype();
- struct ax25 hdr;
- struct ax25_addr *hp;
-
- printf("AX25: ");
- /* Extract the address header */
- if(ntohax25(&hdr,bpp) < 0){
- /* Something wrong with the header */
- printf(" bad header!\n");
- return;
- }
- pax25(tmp,&hdr.source);
- printf("%s",tmp);
- pax25(tmp,&hdr.dest);
- printf("->%s",tmp);
- if(hdr.ndigis > 0){
- printf(" v");
- for(hp = &hdr.digis[0]; hp < &hdr.digis[hdr.ndigis]; hp++){
- /* Print digi string */
- pax25(tmp,hp);
- printf(" %s%s",tmp,(hp->ssid & REPEATED) ? "*":"");
- }
- }
- if(pullup(bpp,&control,1) != 1)
- return;
-
- putchar(' ');
- type = ftype(control);
- printf("%s",decode_type(type));
- /* Dump poll/final bit */
- if(control & PF){
- switch(hdr.cmdrsp){
- case COMMAND:
- printf("(P)");
- break;
- case RESPONSE:
- printf("(F)");
- break;
- default:
- printf("(P/F)");
- break;
- }
- }
- /* Dump sequence numbers */
- if((type & 0x3) != U) /* I or S frame? */
- printf(" NR=%d",(control>>5)&7);
- if(type == I || type == UI){
- if(type == I)
- printf(" NS=%d",(control>>1)&7);
- /* Decode I field */
- if(pullup(bpp,&pid,1) == 1){ /* Get pid */
- switch(pid & (PID_FIRST | PID_LAST)){
- case PID_FIRST:
- printf(" First frag");
- break;
- case PID_LAST:
- printf(" Last frag");
- break;
- case PID_FIRST|PID_LAST:
- break; /* Complete message, say nothing */
- case 0:
- printf(" Middle frag");
- break;
- }
- printf(" pid=");
- switch(pid & 0x3f){
- case PID_ARP:
- printf("ARP\n");
- break;
- case PID_NETROM:
- printf("NET/ROM\n");
- break;
- case PID_IP:
- printf("IP\n");
- break;
- case PID_NO_L3:
- printf("Text\n");
- break;
- default:
- printf("0x%x\n",pid);
- }
- /* Only decode frames that are the first in a
- * multi-frame sequence
- */
- switch(pid & (PID_PID | PID_FIRST)){
- case PID_ARP | PID_FIRST:
- arp_dump(bpp);
- break;
- case PID_IP | PID_FIRST:
- /* Only checksum complete frames */
- ip_dump(bpp,pid & PID_LAST);
- break;
- case PID_NETROM | PID_FIRST:
- netrom_dump(bpp);